#define _CRT_SECURE_NO_WARNINGS 1
#include<math.h>
#include<stdio.h>
int main()
{
	//int rmb = 0;
	//int total = 0;
	//int n = 0;
	//while (rmb < 20)
	//{
	//	rmb++;
	//	total++;
	//	n++;
	//	if (n == 2)
	//	{
	//		n = 0;
	//		total++;
	//	}
	//}
	//printf("%d", total);

	/*int i = 0, j = 0;
	//char arr[13][13] = { 0 };
	//int n = 0;
	//int left = 0;
	//int right = sizeof(arr) / sizeof(arr[0]) - 1;
	//int col = sizeof(arr) / sizeof(arr[0]) - 1;
	//int a = 0, b = 0;
	//int mid = (left + right) / 2;
	//for (i = mid, j = mid; i >= 0, j <= col; i--, j++)
	//{
	//	for (a = n++; a <= col; a++)
	//	{
	//		arr[i][a] = '*';
	//		arr[j][a] = '*';
	//	}
	//	col--;
	//}
	//for (i = 0; i < 13; i++)
	//{
	//	for (j = 0; j < 13; j++)
	//		printf("%c", arr[i][j]);
	//	printf("\n");
	//}*/

	int i = 0;
	for (i = 0; i <= 100000; i++)
	{
		int sum = 0;
		int temp = i;
		int count = 0;
		while (temp)
		{
			count++;
			temp /= 10;
		}
		temp = i;
		while (temp)
		{
			sum += pow(temp % 10, count);
			temp /= 10;
		}
		if (sum == i)
			printf("%d ", i);
	}
	return 0;
}